package com.hutou.chuangke.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.hutou.chuangke.R;

/**
 * Created by Administrator on 2017/5/8.
 */

public class NetDailog extends Dialog{
    private Context context;
    public NetDailog(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.setContentView(R.layout.dialog_net_waiting);
        setCanceledOnTouchOutside(false);
        setDialogAttributes();

    }

    public void setDialogAttributes() {
        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.CENTER);

        WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE);
        lp.gravity = Gravity.CENTER;

        lp.height = (int)(wm.getDefaultDisplay().getHeight()*0.15);
//		lp.width = wm.getDefaultDisplay().getWidth() - 100;
        lp.width=(int)(wm.getDefaultDisplay().getWidth()*0.5);
        dialogWindow.setAttributes(lp);

        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));// 去掉Dialog边框
    }
}
